/*
 * @Description:
 * @Author: maxyang
 * @Date: 2022-06-05 10:01:20
 * @LastEditTime: 2022-08-10 11:39:14
 * @LastEditors: liutq
 * @Reference:
 */
package router

import (
	"github.com/gin-gonic/gin"
	"github.com/maxyang107/jinglan/controller/announcement"
	"github.com/maxyang107/jinglan/controller/auth"
	"github.com/maxyang107/jinglan/controller/banner"
	"github.com/maxyang107/jinglan/controller/callback"
	"github.com/maxyang107/jinglan/controller/goods"
	"github.com/maxyang107/jinglan/controller/oss"
	"github.com/maxyang107/jinglan/controller/pay"
	"github.com/maxyang107/jinglan/controller/user"
	"github.com/maxyang107/jinglan/middleware"
)

func LoadClientRouter(router *gin.Engine) {

	v1 := router.Group("/api")
	//用户鉴权
	v1.POST("/login", auth.Login)
	v1.POST("/register", auth.Register)
	v1.GET("/sendsmscode", auth.SendSmsCode)
	v1.POST("/modifypassword", auth.ModifyPassword)
	v1.GET("/getuserinfo", middleware.JwtAuthMiddleware(), user.GetUserInfo)

	//商品路由
	v1.GET("/goodslist", goods.GetGoodsList)
	//商品详情
	v1.GET("/goodsdetail", middleware.JwtAuthMiddleware(), goods.GetGoodsDetail)
	//获取抽签商品列表
	v1.GET("/getgoodslistfordraw", middleware.JwtAuthMiddleware(), goods.GetGoodsListForDraw)
	//抽签
	v1.POST("/adddrawrecord", middleware.JwtAuthMiddleware(), goods.AddDrawRecord)
	//同步微店订单
	v1.POST("/synchronize", middleware.JwtAuthMiddleware(), goods.Synchronize)

	//获取邀请列表
	v1.GET("/getinvitelist", middleware.JwtAuthMiddleware(), user.GetInviteList)
	//获取邀请排行
	v1.GET("/getinviteranklist", middleware.JwtAuthMiddleware(), user.GetInviteRankList)
	//获取用户收藏列表
	v1.GET("/getusercollectlist", middleware.JwtAuthMiddleware(), user.GetUserCollectList)
	//获取藏品详情
	v1.GET("/getusercollectbyid", middleware.JwtAuthMiddleware(), user.GetUserCollectById)
	//开盲盒
	v1.POST("/openblindbox", middleware.JwtAuthMiddleware(), user.OpenBlindBox)

	//获取公告列表
	v1.GET("/getannouncementlist", announcement.GetAnnouncementList)
	//获取公告详情
	v1.GET("/getannouncementdetail", announcement.GetAnnouncementDetail)

	v1.GET("/provisionalauthorization", middleware.JwtAuthMiddleware(), oss.ProvisionalAuthorization)
	//回购
	v1.POST("/addreporecord", middleware.JwtAuthMiddleware(), goods.AddRepoRecord)

	v1.GET("/vshopOrderDealNotice", callback.VshopOrderDealNotice)
	v1.GET("/getbannerlist", banner.GetBannerList)
	//支付宝支付接口
	v1.GET("/aliPay", middleware.JwtAuthMiddleware(), pay.AliPay)

	//支付宝回调地址
	v1.GET("/aliNotify", pay.AliNotify)
	v1.POST("/aliNotify", pay.AliNotify)

	v1.GET("/test", func(ctx *gin.Context) {
		s := ctx.Request.Header.Get("X-Real-IP")
		ctx.JSON(200, gin.H{
			"test": "ok",
			"code": 200,
			"ip":   s,
		})
	})

}
